#!/bin/bash
###########################first edit network hostname yum makecache ###############################

n=0
m=0
filenameshow=0
###################

function ethname(){
filenameshow=`find  /etc/sysconfig/network-scripts/ -name ifcfg-eth* -type f|sed -nr 's#(/etc/sysconfig/network-scripts/ifcfg-)(.*$)#\2#gp'`
}


###################   rename network name!
echo "please input network-scripts ifcfg-eth* .We find your system filename and show it,you just input the number"



ethname
echo "$filenameshow rename eth(?)"
read -p "?=" n

/bin/mv /etc/sysconfig/network-scripts/ifcfg-$filenameshow /etc/sysconfig/network-scripts/ifcfg-eth$n


##################    change eth set

ethname

echo "Please input network eth(IPADDR),if you dont know,you will try ifconfig -a"
read -p "IPADDR=?.?.?.?" m

sed -i  s#DEVICE=eth.*#DEVICE=eth$n#g /etc/sysconfig/network-scripts/ifcfg-$filenameshow

sed -i  s#IPADDR=.*#IPADDR=$m#g /etc/sysconfig/network-scripts/ifcfg-$filenameshow

ls /etc/sysconfig/network-scripts/ifcfg-$filenameshow
cat /etc/sysconfig/network-scripts/ifcfg-$filenameshow


ifdown $filenameshow
ifup $filenameshow
####################   change hostname

newname=0
echo "you will change hostname"
read -p "hostname=" hostname
sed -i s#HOSTNAME=.*#HOSTNAME=$hostname#g /etc/sysconfig/network
cat /etc/sysconfig/network
hostname $hostname

####################    yum   makecache

rm -rf /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo
yum makecache



####################   /bin/bash
/bin/bash
